<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  var str = "中文";

  console.log( str.charCodeAt(0) );

  console.log( String.fromCharCode( 20013 ) );

  console.log( "\u4e2d" );
  
  console.log( String.fromCharCode( "0x4e2d" ) );

  console.log( "0x4e2d" );

  // Unicode编码可以直接被计算机支持
  // String.fromCharCode()
  // 只能支持十进制和十六进制
  // 十六进制的表示方式为：0x开头
  // 不支持Unicode编码

  // 生僻字

  var str2 = '𠮶';
  console.log( str2[0] );
  console.log( str2[1] );

  console.log( str2.length );

  console.log( str2.charCodeAt(0) );
  console.log( str2.charCodeAt(1) );

  console.log( String.fromCharCode( 55362, 57270 ) );
  
  // ES6提供的新的转换法方法
  console.log( str2.codePointAt(0) );
  console.log( String.fromCodePoint( 134070 ) );
  
  console.log("中国".codePointAt(0))
  console.log( String.fromCodePoint( 20013 ) );

</script>
</html>